
/**
\file
Definition of the nmn::singleton_proxy helper struct.
\author Sean Tromans
*/

#ifndef	NMN_SINGLETON_PROXY_HPP
#define	NMN_SINGLETON_PROXY_HPP

namespace nmn
{

	/**
	Wrapper object for a singleton to be used with boost/std bind and function.
	\author Sean Tromans
	*/
	template < typename TSingleton >
	struct singleton_proxy
	{
		typedef TSingleton * ptr_type;

		operator ptr_type ( ) const
		{
			return get_pointer( );
		}

		ptr_type get_pointer( ) const
		{
			return TSingleton::get_singleton( ).get( );
		}
	};

	/**
	Override for boost/std::get_pointer to all for the boost/std::bind integration.
	@return	The pointer to the singleton, T.
	\author Sean Tromans
	*/
	template < typename T >
	inline T* get_pointer( singleton_proxy<T> const & p )
	{
		return p.get_pointer( );
	}

}

#endif	//NMN_SINGLETON_PROXY_HPP
